---
title: Getting Started
sidebar:
  order: 1
---

import { Tabs, TabItem } from '@astrojs/starlight/components';

## Requirements

Knip v5 requires Node.js v18.6 or higher. Or Bun.

Looking for docs of previous versions? Go to [v3.knip.dev][1] or
[v4.knip.dev][2].

## Installation

This is the easiest and recommended way to install Knip:

<Tabs>
  <TabItem label="npm">

    ```shell
    npm init @knip/config
    ```

  </TabItem>

  <TabItem label="pnpm">

    ```shell
    pnpm create @knip/config
    ```

  </TabItem>

  <TabItem label="yarn">

    ```shell
    yarn create @knip/config
    ```

  </TabItem>
</Tabs>

Now you can run Knip to lint your project:

<Tabs>
  <TabItem label="npm">

    ```shell
    npm run knip
    ```

  </TabItem>

  <TabItem label="pnpm">

    ```shell
    pnpm knip
    ```

  </TabItem>

  <TabItem label="bun">

    ```shell
    bun knip
    ```

  </TabItem>

  <TabItem label="yarn">

    ```shell
    yarn knip
    ```

  </TabItem>
</Tabs>

Knip will lint your project and report unused files, dependencies and exports.

You can skip the rest of this page and go to [configuration][3].

## Manual

Alternatively, you can manually install Knip using your package manager:

<Tabs>
  <TabItem label="npm">

    ```shell
    npm install -D knip typescript @types/node
    ```

  </TabItem>

  <TabItem label="pnpm">

    ```shell
    pnpm add -D knip typescript @types/node
    ```

  </TabItem>

  <TabItem label="bun">

    ```shell
    bun add -D knip typescript @types/node
    ```

  </TabItem>

  <TabItem label="yarn">

    ```shell
    yarn add -D knip typescript @types/node
    ```

  </TabItem>
</Tabs>

Knip uses `typescript` and ` @types/node` as peer dependencies to increase
compatibility with your project. No worries, they're probably in your
`node_modules` already.

Then add a `knip` script to your `package.json`:

```json title="package.json"
{
  "name": "my-project",
  "scripts": {
    "knip": "knip"
  }
}
```

## Without installation

To run Knip without adding it to your project:

<Tabs>
  <TabItem label="npm">

    ```shell
    npx knip
    ```

  </TabItem>

  <TabItem label="pnpm">

    ```shell
    pnpm dlx knip
    ```

  </TabItem>

  <TabItem label="bun">

    ```shell
    bunx knip
    ```

  </TabItem>
</Tabs>

In this scenario `typescript` and `@types/node` are expected to be installed
already.

[1]: https://v3.knip.dev/overview/getting-started
[2]: https://v4.knip.dev/overview/getting-started
[3]: ./configuration.md
